home *** CD-ROM | disk | FTP | other *** search
/ Programmer Power Tools / Programmer Power Tools.iso / microcrn / issue_46.arc / ISR.ARC / ISRHT.C < prev    next >
Encoding:
Text File  |  1988-05-11  |  1.3 KB  |  76 lines

  1. /*    ISRHT - isr handler template.
  2.  
  3.         Supports ISR article in Micro Cornucopia Magazine Issue #46
  4. */
  5.  
  6.  
  7. #asm
  8.  
  9. dataseg    segment para public 'data'
  10.     extrn    _Dorg_:byte
  11.  
  12.     public  _ISRHT_LENGTH_, _ISRHT_PTR_
  13.  
  14. _ISRHT_LENGTH_   dw (offset p2 - offset p1)
  15. _ISRHT_PTR_      dw offset p1
  16.              dw seg p1
  17.  
  18. dataseg ends
  19.  
  20.     ;This code gets moved later to a structure in RAM.
  21.     ;The correct SS and SP values, as well as the
  22.     ;address of the 'C function to call, are installed
  23.     ;at that time.
  24.  
  25. codeseg    segment para public 'code'
  26.  
  27. p1:
  28.     public  isr_template
  29. isr_template proc far    
  30.  
  31.         ;flags
  32.         ;CS
  33.         ;IP
  34.     push    bp        ;save the callers registers
  35.     push    si
  36.     push    di
  37.     push    ds
  38.     push    dx
  39.     push    ax
  40.     push    cx
  41.     push    es
  42.     push    bx
  43.  
  44.     mov    ax, seg _Dorg_    ;get the local data segment value
  45.     mov    ds, ax
  46.     mov    es, ax
  47.  
  48.     mov     ax, 0           ;push a pointer to the ISRH
  49.     push    ax
  50.     mov     ax, 0           ;(zeros will be replaced later)
  51.     push    ax
  52.  
  53.     call    isr_template    ;(isr_template will also be replaced)
  54.  
  55.     pop     ax              ;restore the pointer that we pushed
  56.     pop     ax
  57.  
  58.     pop    bx        ;restore callers registers
  59.     pop    es
  60.     pop    cx
  61.     pop    ax
  62.     pop    dx
  63.     pop    ds
  64.     pop    di
  65.     pop    si
  66.     pop    bp
  67.     jmp     isr_template    ;jump to previous handler
  68.  
  69. isr_template endp
  70.     ;
  71. p2:
  72.  
  73. codeseg ends
  74.  
  75. #endasm
  76.